package com.holike.crm.fragment.monthdata;


import com.holike.crm.R;
import com.holike.crm.base.MyFragment;
import com.holike.crm.bean.MonthDataBossBean;
import com.holike.crm.presenter.fragment.MonthDataBossPresenter;
import com.holike.crm.view.fragment.MonthDataBossView;

import java.util.Date;


/**
 * Created by pony on 2019/8/12.
 * Copyright holike possess 2019.
 * 老板本月数据
 */
public class BossMonthDataFragment extends MyFragment<MonthDataBossPresenter,
        MonthDataBossView> implements MonthDataHelper.Callback, MonthDataBossView {
    private BossMonthDataHelper mHelper;

    @Override
    protected MonthDataBossPresenter attachPresenter() {
        return new MonthDataBossPresenter();
    }

    @Override
    protected int getLayoutResourceId() {
        return R.layout.fragment_month_data_boss;
    }

    @Override
    protected void init() {
        mHelper = new BossMonthDataHelper(this, this);
    }

    @Override
    public void onQuery(String type, String cityCode, Date startDate, Date endDate) {
        showLoading();
        mPresenter.getMonthData(type, cityCode, startDate, endDate);
    }

    @Override
    public void onSuccess(MonthDataBossBean bean) {
        dismissLoading();
        mHelper.onSuccess(bean);
    }

    @Override
    public void onFailure(String failReason) {
        dismissLoading();
        mHelper.onFailure(failReason);
    }

    @Override
    public void reload() {
        mHelper.onQuery();
    }

    @Override
    public void onDestroyView() {
        mHelper.onDestroy();
        super.onDestroyView();
    }
}
